import 'package:citiesocial/_include.dart';
import 'package:citiesocial/ui/goods/goods_by_hot.dart';

///
///4个商品的组件，目前就用于首页的“即时排行”
///
class FourGoods extends StatelessWidget {
  final _fontSize = 20.0,
      _fontPadding = 10.0,
      _lineMargin = 120.0,
      _gridMargin = 10.0;

  final String title, url;
  final List<GoodsEntity> goodsList;

  FourGoods(this.title, {this.url, this.goodsList}) : super();

  @override
  Widget build(BuildContext context) => Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            child: Text(
              '$title',
              style: TextStyle(
                fontSize: _fontSize,
              ),
            ),
            padding: EdgeInsets.only(top: _fontPadding),
          ),
          Container(
            child: Wrap(
              children: List.generate(goodsList == null ? 0 : goodsList.length,
                  (index) {
                return SquareGoodsItem(
                  goodsList[index],
                  width:
                      (MediaQuery.of(context).size.width - _gridMargin * 4) / 2,
                  margin: EdgeInsets.symmetric(horizontal: _gridMargin / 2),
                );
              }),
            ),
            margin: EdgeInsets.symmetric(horizontal: _gridMargin),
          ),
          Container(
            child: Configs.dividerMainColor,
            margin: EdgeInsets.symmetric(horizontal: 20.0),
          ),
          SeeMore(
            onTap: () {
              Navigator.push(context,
                  MaterialPageRoute(builder: (context) => GoodsByHot()));
            },
          ),
          Container(
            decoration: BoxDecoration(
                shape: BoxShape.rectangle, color: Configs.background),
            height: 10.0,
          ),
        ],
      );
}
